Skip to content

Replace DynVarBinBuilder with a generic VarBinBuilder - #9096

Open
robert3005 wants to merge 4 commits into
developfrom
rk/varbin-builder-trait
Open

Replace DynVarBinBuilder with a generic VarBinBuilder#9096
robert3005 wants to merge 4 commits into
developfrom
rk/varbin-builder-trait

Conversation

@robert3005

@robert3005 robert3005 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

DynVarBinBuilder was unncessary but through all of builder migrations we have made VarBinBuilder not an actual ArrayBuilder. This pr fixes VarBinBuilder builder behaviour and replaces all usages of DynVarBinBuilder with appropriate downcast of VarBinBuilder. After #9053 VarBinBuilder offsets should be constrainted to the same bound

`VarBinBuilder<O>` becomes an actual `ArrayBuilder`, carrying its own `DType`
and offset width, so `DynVarBinBuilder` is no longer needed as a separate
type-erasing wrapper.

Encodings recover the concrete offset width from a `&mut dyn ArrayBuilder`
with the new `match_each_varbin_builder!` (i32/i64) and
`match_each_any_varbin_builder!` (every width) macros, which monomorphize the
append body over the width instead of dispatching through `dyn`. The existing
`append_to_builder` specializations for FSST, OnPair and Zstd are ported over
mechanically; their optimizations follow in later commits.

Because the builder's offset type now matches the Arrow target, the Arrow byte
export hands the offsets buffer straight to Arrow with no cast, which also
removes the `VarBinView` + `arrow_cast` round trip a `Utf8`/`Binary` dtype
mismatch used to take. A `Binary` source exported to `Utf8` instead validates
the bytes of its live values, skipping the extents of null slots that
`GenericByteArray::try_new` would have rejected.

Also adds `BinaryView::bytes`, which borrows from already-resolved buffer
slices instead of cloning a buffer handle per row.

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
@robert3005
robert3005 force-pushed the rk/varbin-builder-trait branch from 56ebb9a to 79d9d41 Compare July 31, 2026 13:51
I, Robert Kruszewski <github@robertk.io>, hereby add my Signed-off-by to this commit: 79d9d41

Signed-off-by: Robert Kruszewski <github@robertk.io>
@codspeed-hq

codspeed-hq Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.9%

❌ 2 regressed benchmarks
✅ 1840 untouched benchmarks
⏩ 55 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation execute_scalar_struct_simple 426.6 µs 483 µs -11.67%
Simulation execute_scalar_struct_wide 2 ms 2.3 ms -10.13%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/varbin-builder-trait (e072374) with develop (08c336f)

Open in CodSpeed

Footnotes

  1. 55 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Comment thread vortex-array/src/arrays/constant/vtable/mod.rs
Signed-off-by: Robert Kruszewski <github@robertk.io>
…lder

- Add a regression test that appends VarBinView, VarBin and Constant arrays to a
  VarBinBuilder of all four offset widths, so a macro that only matched the
  signed pair would fail here instead of panicking at runtime (onursatici).
- Replace `append_value_slices` with `append_valid_slices`, which takes a
  `FnMut(usize) -> &[u8]` instead of an iterator. Valid rows are walked with
  `BitBuffer::for_each_set_index` a word at a time rather than pulled through
  `set_indices()`, and the `ValidValues` iterator adapter goes away.

Signed-off-by: Robert Kruszewski <github@robertk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/break A breaking API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants